﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Google.Picasa;
using Google.GData.Photos;
using System.Collections.Generic;
using System.Drawing.Imaging;
using System.Drawing;
using Google.GData.Extensions;
using Google.GData.Extensions.Location;
using Google.GData.Client;
using Google.GData.Spreadsheets;


namespace Copycat
{
    public partial class _Default : System.Web.UI.Page
    {
        private List<System.Drawing.Image> Images;

        protected void Page_Load(object sender, EventArgs e)
        {
            LoadImagesFromPicasa();

            SpreadsheetsService service;
            SpreadsheetFeed feed;

            try
            {
                service = new SpreadsheetsService("NewsletterService");

                // TODO: Authorize the service object for a specific user (see other sections)
                service.Credentials = new GDataCredentials("jobs.copycat@gmail.com", "copycat_2012");

                // Instantiate a SpreadsheetQuery object to retrieve spreadsheets.
                SpreadsheetQuery query = new SpreadsheetQuery();

                // Make a request to the API and get all spreadsheets.
                feed = service.Query(query);

                Session["Service"] = service;
                Session["Feed"] = feed;

            }
            catch
            {
                return;
            }

          

        }

        [System.Web.Services.WebMethod]
        [System.Web.Script.Services.ScriptMethod]
        public static AjaxControlToolkit.Slide[] GetSlides()
        {
            AjaxControlToolkit.Slide[] slides = new AjaxControlToolkit.Slide[5];
            
            PicasaService service = new PicasaService("Picasa Album");
            service.setUserCredentials("jobs.copycat@gmail.com", "copycat_2012");
            PhotoQuery query = new PhotoQuery(PicasaQuery.CreatePicasaUri("118403632400317537044", "5820269967970171825"));
            PicasaFeed feed = service.Query(query);


            List<AjaxControlToolkit.Slide> slidesList = new List<AjaxControlToolkit.Slide>();
            foreach (PicasaEntry entry in feed.Entries)
            {
                slidesList.Add(new AjaxControlToolkit.Slide(entry.Media.Content.Url, entry.Title.Text.Substring(0, entry.Title.Text.LastIndexOf("."))
                    ,""));
                
                //System.Drawing.Image img = new Bitmap();
                //Images.Add(img);
            }

            return slidesList.ToArray();
            //slides[0] = new AjaxControlToolkit.Slide("images/1.jpg", "1", "Cool moon night...");
            //slides[1] = new AjaxControlToolkit.Slide("images/2.jpg", "2", "Red moon desert...");
            //slides[2] = new AjaxControlToolkit.Slide("images/3.jpg", "3", "Beautiful tulips...");
            //slides[3] = new AjaxControlToolkit.Slide("images/4.jpg", "4", "Way to home...");
            //return (slides);
        }

        private void LoadImagesFromPicasa()
        {

            Images = new List<System.Drawing.Image>();


           
        }


        protected void btnOutdoorBranch_Click(object sender, ImageClickEventArgs e)
        {
           // btnHeadOffice.ImageUrl = "~/Images/Head.jpg";
          //  btnOutdoorBranch.ImageUrl = "~/Images/outdoorActive.jpg";
        }

        protected void btnHeadOffice_Click(object sender, ImageClickEventArgs e)
        {
          //  btnOutdoorBranch.ImageUrl = "~/Images/outdoor.jpg";
          //  btnHeadOffice.ImageUrl = "~/Images/HeadActive.jpg";
        }
    }
    
}
